home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / pars.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  11KB  |  375 lines

  1. /*
  2.     GWAda Development Environment for 386/486 PCs   
  3.     Copyright (C) 1993, Arthur Vargas Lopes  & Michael Bliss Feldman
  4.                         vlopes@vortex.ufrgs.br mfeldman@seas.gwu.edu
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; version 2 of the License.    
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. /*  Pars.c  */
  21.  
  22. #include <externs.h>
  23.  
  24. static avl_cur_par = 0;
  25.  
  26.  
  27. void AVL_SET_MONITOR() 
  28. {
  29.     AVL_WIN_PTR hw, hw2;
  30.     short h, co;
  31.     char opts[6];
  32.     char msg[80];
  33.     int ch;
  34.     char old;
  35.     old = avl_monitor_on;
  36.     hw2 = AVL_MAKE_WINDOW("",18,7,21,77,avl_wnd_bk_color,avl_wnd_color);
  37.     _outtext(" Set the Parallel Monitoring On/Off:\n");
  38.     _outtext(" ESC-Cancel  ENTER-Ok  Type the digit to set/reset the option.");
  39.     _settextposition(2,2); 
  40.     co = _settextcolor(avl_men_ready);
  41.     _outtext("ESC");
  42.     _settextposition(2,14); 
  43.     _outtext("ENTER");
  44.     _settextcolor(co);
  45.     hw = AVL_MAKE_WINDOW(" Monitoring ",5,2,7,79,avl_wnd_bk_color,avl_wnd_color);
  46.     _outtext(" 1. Off  Source line monitoring");
  47.     _settextcursor(0x2000);
  48.     while ( 1 )   {
  49.         _settextposition(1,5); 
  50.         if (avl_monitor_on) {
  51.             _settextcolor(avl_men_ready);
  52.             _outtext("On "); 
  53.             }
  54.         else  { 
  55.             _settextcolor(avl_men_letter);
  56.             _outtext("Off");
  57.             }
  58.         ch = getch();
  59.         if (ch == '1')   {
  60.             h = ch - '1';
  61.             avl_monitor_on = !avl_monitor_on;
  62.             }
  63.         else if (ch == 27) {avl_monitor_on = old; break; }
  64.         else if (ch == 13)  
  65.             break;
  66.         else if (ch == 0) ch = getch();
  67.         }
  68.     AVL_DEL_WINDOW(hw);
  69.     AVL_DEL_WINDOW(hw2);
  70.         
  71. }
  72.  
  73.  
  74. void AVL_SET_TRACE() 
  75. {
  76.     AVL_WIN_PTR hw, hw2;
  77.     short h, co;
  78.     char opts[6];
  79.     char msg[80];
  80.     int ch;
  81.     hw2 = AVL_MAKE_WINDOW("",18,9,21,78,avl_wnd_bk_color,avl_wnd_color);
  82.     _outtext(" Specify the kind of trace requested for the program's execution:\n");
  83.     _outtext(" ESC-Cancel    ENTER-Ok    Type the digit to set/reset an option.");
  84.     _settextposition(2,2); 
  85.     co = _settextcolor(avl_men_ready);
  86.     _outtext("ESC");
  87.     _settextposition(2,16); 
  88.     _outtext("ENTER");
  89.     _settextcolor(co);
  90.     hw = AVL_MAKE_WINDOW(" Trace ",5,2,13,79,avl_wnd_bk_color,avl_wnd_color);
  91.     _outtext(" 1. Off  Display the source line numbers.\n");
  92.     _outtext("         There is no need to recompile the program.\n");
  93.     _outtext(" 2. Off  Display the name of each routine as it is entered and exited.\n");
  94.     _outtext(" 3. Off  Display the name of each exception as it is raised.\n");
  95.     _outtext(" 4. Off  Trace each rendezvous.\n");
  96.     _outtext(" 5. Off  Display the context-switches between tasks.\n");
  97.     _outtext(" 6. Off  Display task creation, activation, and termination.");
  98.     for(h = 0; h < 6; ++h)
  99.         opts[h] = avl_trace_opts[h];
  100.     _settextcursor(0x2000);
  101.     while ( 1 )   {
  102.         _settextposition(1,5); 
  103.         if (opts[0]) {
  104.             _settextcolor(avl_men_ready);
  105.             _outtext("On "); 
  106.             }
  107.         else  { 
  108.             _settextcolor(avl_men_letter);
  109.             _outtext("Off");
  110.             }
  111.         _settextposition(3,5); 
  112.         if (opts[1]) {
  113.             _settextcolor(avl_men_ready);
  114.             _outtext("On "); 
  115.             }
  116.         else  { 
  117.             _settextcolor(avl_men_letter);
  118.             _outtext("Off");
  119.             }
  120.         _settextposition(4,5); 
  121.         if (opts[2]) {
  122.             _settextcolor(avl_men_ready);
  123.             _outtext("On "); 
  124.             }
  125.         else  { 
  126.             _settextcolor(avl_men_letter);
  127.             _outtext("Off");
  128.             }
  129.         _settextposition(5,5); 
  130.         if (opts[3]) {
  131.             _settextcolor(avl_men_ready);
  132.             _outtext("On "); 
  133.             }
  134.         else  { 
  135.             _settextcolor(avl_men_letter);
  136.             _outtext("Off");
  137.             }
  138.         _settextposition(6,5); 
  139.         if (opts[4]) {
  140.             _settextcolor(avl_men_ready);
  141.             _outtext("On "); 
  142.             }
  143.         else  { 
  144.             _settextcolor(avl_men_letter);
  145.             _outtext("Off");
  146.             }
  147.         _settextposition(7,5); 
  148.         if (opts[5]) {
  149.             _settextcolor(avl_men_ready);
  150.             _outtext("On "); 
  151.             }
  152.         else  { 
  153.             _settextcolor(avl_men_letter);
  154.             _outtext("Off");
  155.             }
  156.         ch = getch();
  157.         if (ch >= '1' && ch <= '6')   {
  158.             h = ch - '1';
  159.             opts[h] = !opts[h];
  160.             }
  161.         else if (ch == 27) break;
  162.         else if (ch == 13)  {
  163.             for(h = 0; h < 6; ++h)
  164.                 avl_trace_opts[h] = opts[h];
  165.             break;
  166.             }
  167.         }
  168.     AVL_DEL_WINDOW(hw);
  169.     AVL_DEL_WINDOW(hw2);
  170.         
  171. /* -t [acerst]  */
  172. }
  173.  
  174. void AVL_SET_SCHEDULER() 
  175. {
  176.     AVL_WIN_PTR hw, hw2;
  177.     short h;
  178.     char msg[80];
  179.     hw2 = AVL_MAKE_WINDOW("",18,3,24,77,avl_wnd_bk_color,avl_wnd_color);
  180.     _outtext(" Invoke a 'round-robin' scheduling policy instead of the 'run-until-\n");
  181.     _outtext(" -block' default scheduling policy and specify the maximum number of\n");
  182.     _outtext(" interpreted statements that a given task can execute before switching\n");
  183.     _outtext(" to another task. (the minimum value is 1).\n");
  184.     _outtext(" A value 0 sets the 'run-until-block' schedulling policy.");
  185.     hw = AVL_MAKE_WINDOW(" Scheduller ",13,20,13+2
  186.                                          ,63,avl_wnd_bk_color,avl_wnd_color);
  187.     while ( 1 )   {
  188.         sprintf(msg,"%d", avl_scheduller);
  189.         if (AVL_PROMPT(1,3,msg,3)) break;
  190.         if (strlen(msg) > 0) {
  191.             h = atoi(msg);
  192.             if (h < 0) AVL_ERROR("Invalid number of interpreted statements."); 
  193.             else {
  194.                 avl_scheduller = h;
  195.                 break;
  196.                 }
  197.             }
  198.         }
  199.     AVL_DEL_WINDOW(hw);
  200.     AVL_DEL_WINDOW(hw2);
  201.         
  202. /* -r number_of_statements (an integer)*/
  203. }
  204.  
  205.  
  206. void AVL_SET_TASK_STACK() 
  207. {
  208.     AVL_WIN_PTR hw, hw2;
  209.     short h;
  210.     char msg[80];
  211.     hw2 = AVL_MAKE_WINDOW("",18,3,24,76,avl_wnd_bk_color,avl_wnd_color);
  212.     _outtext(" Specifies the size in bytes of the stack size for each new task.\n");
  213.     _outtext(" The default is 2048. Argument values in the range 1..31 are multiplied\n");
  214.     _outtext(" by 1024 to obtain the stack size in bytes. Use of small stack sizes\n");
  215.     _outtext(" may be appropriate when executing programs with many tasks, each of\n");
  216.     _outtext(" which can run with a small stack.  The maximum value is 32767.");
  217.     hw = AVL_MAKE_WINDOW(" Task Stack ",13,20,13+2
  218.                                          ,63,avl_wnd_bk_color,avl_wnd_color);
  219.     while ( 1 )   {
  220.         sprintf(msg,"%d", avl_task_stack);
  221.         if (AVL_PROMPT(1,3,msg,3)) break;
  222.         if (strlen(msg) > 0) {
  223.             h = atoi(msg);
  224.             if (h <= 0) AVL_ERROR("Invalid task stack."); 
  225.             else {
  226.                 avl_task_stack = h;
  227.                 break;
  228.                 }
  229.             }
  230.         }
  231.     AVL_DEL_WINDOW(hw);
  232.     AVL_DEL_WINDOW(hw2);
  233.         
  234. /*  -s tstack  */
  235. }
  236.  
  237.  
  238. void AVL_SET_HEAP_SIZE()
  239. {
  240.     AVL_WIN_PTR hw, hw2;
  241.     short h;
  242.     char msg[80];
  243.     hw2 = AVL_MAKE_WINDOW("",18,4,24,75,avl_wnd_bk_color,avl_wnd_color);
  244.     _outtext(" Specifies the size of the heap increment in kilowords, by which the\n");
  245.     _outtext(" heap is expanded when the elaboration of a new entity requires it.\n");
  246.     _outtext(" The heap expands to fill available memory. The default increment is\n");
  247.     _outtext(" 32. This parameter limits the size of the largest object that can be\n");
  248.     _outtext(" created in a program.");
  249.     hw = AVL_MAKE_WINDOW(" Heap Size ",13,20,13+2
  250.                                          ,63,avl_wnd_bk_color,avl_wnd_color);
  251.     while ( 1 )   {
  252.         sprintf(msg,"%d", avl_heap);
  253.         if (AVL_PROMPT(1,3,msg,3)) break;
  254.         if (strlen(msg) > 0) {
  255.             h = atoi(msg);
  256.             if (h <= 0) AVL_ERROR("Invalid heap size."); 
  257.             else {
  258.                 avl_heap = h;
  259.                 break;
  260.                 }
  261.             }
  262.         }
  263.     AVL_DEL_WINDOW(hw);
  264.     AVL_DEL_WINDOW(hw2);
  265.         
  266. /*  -h heap  */
  267. }
  268.  
  269.  
  270.  
  271. void AVL_SET_PGM_STACK() 
  272. {
  273.     AVL_WIN_PTR hw, hw2;
  274.     short h;
  275.     char msg[80];
  276.     hw2 = AVL_MAKE_WINDOW("",19,5,24,75,avl_wnd_bk_color,avl_wnd_color);
  277.     _outtext(" Specifies the size in bytes of the program stack size for the main\n");
  278.     _outtext(" task. The default is 4096. Argument values in the range 1..31 are\n");
  279.     _outtext(" multiplied by 1024 to obtain the stack size in bytes. The maximum\n");
  280.     _outtext(" value is 32767. ");
  281.     hw = AVL_MAKE_WINDOW(" Program Stack ",13,20,13+2
  282.                                           ,63,avl_wnd_bk_color,avl_wnd_color);
  283.     while ( 1 )   {
  284.         sprintf(msg,"%d", avl_pgm_stack);
  285.         if (AVL_PROMPT(1,3,msg,3)) break;
  286.         if (strlen(msg) > 0) {
  287.             h = atoi(msg);
  288.             if (h <= 0) AVL_ERROR("Invalid stack size."); 
  289.             else {
  290.                 avl_pgm_stack = h;
  291.                 break;
  292.                 }
  293.             }
  294.         }
  295.     AVL_DEL_WINDOW(hw);
  296.     AVL_DEL_WINDOW(hw2);
  297.         
  298. /*  -p pstack */
  299. }
  300.  
  301. void AVL_SET_PARAMETERS()
  302. {
  303.     AVL_BIND_SIZE c[7];
  304.     PROC_NAME rot[7] = {AVL_SET_MONITOR
  305.                        ,AVL_SET_HEAP_SIZE
  306.                        ,AVL_SET_PGM_STACK
  307.                        ,AVL_SET_TASK_STACK
  308.                        ,AVL_SET_SCHEDULER
  309.                        ,AVL_SET_TRACE
  310.                        ,NULL};
  311.     int i;
  312.     int save_unit;
  313.     int ch, cols = 16, rows = 6;
  314.     AVL_WIN_PTR hw, hw2;
  315.     strcpy(c[0].name,"Monitoring");
  316.     strcpy(c[1].name,"Heap Size");
  317.     strcpy(c[2].name,"Program Stack");
  318.     strcpy(c[3].name,"Task Stack");
  319.     strcpy(c[4].name,"Scheduller");
  320.     strcpy(c[5].name,"Trace");
  321.     save_unit = avl_cur_unit;
  322.     avl_cur_unit = avl_cur_par;
  323.     avl_size = rows;
  324.  
  325.     hw2 = AVL_MAKE_WINDOW("",15,55,15+9,55+24,avl_wnd_bk_color,avl_wnd_color);
  326.     _outtext(" Use the arrow keys to\n");
  327.     _outtext(" go over the  options.\n");
  328.     _outtext("\n");
  329.     _outtext(" Press  <enter>  to\n");
  330.     _outtext(" select an option or\n");
  331.     _outtext(" type the option's no.\n");
  332.     _outtext("\n");
  333.     _outtext(" Press ESC to  cancel.");
  334.     hw = AVL_MAKE_WINDOW(" Parameters ",3,avl_menu[6].c,3+rows+1,avl_menu[6].c+cols+5,avl_wnd_bk_color,avl_wnd_color);
  335.     while ( 1 )  {
  336.         AVL_SHOW_UNIT(c,cols);
  337.         ch = getch();
  338.         if ((ch >= '1' && ch <= '6') || (ch == 13)) {
  339.             if (ch != 13)
  340.                 avl_cur_unit += (ch - '0' - 1);
  341.             avl_cur_par = avl_cur_unit;
  342.             avl_cur_unit = save_unit;
  343.             rot[avl_cur_par]();
  344.             }
  345.         else {
  346.             if (ch == 0 || ch == 0xE0) {
  347.                 ch = getch();
  348.                 switch( ch ) {
  349.                        case 72 : /* Up */ 
  350.                            if (--avl_cur_unit < 0)  
  351.                             avl_cur_unit = avl_size - 1;
  352.                            break;
  353.                        case 80 : /* Down */ 
  354.                            if (++avl_cur_unit >= avl_size)
  355.                                avl_cur_unit = 0;
  356.                            break;
  357.                        default : putchar(7); break;
  358.                        }
  359.                 continue;
  360.                 }
  361.             if (ch == 27)  {
  362.                 AVL_DEL_WINDOW(hw);
  363.                 AVL_DEL_WINDOW(hw2);
  364.                 avl_cur_par = avl_cur_unit;
  365.                 avl_cur_unit = save_unit;
  366.                 return;
  367.                 }
  368.             putch(7);
  369.             continue;
  370.             }
  371.         }
  372. }
  373.  
  374.  
  375.